<?php
session_start();
set_time_limit(0);
if (isset($_POST['name']) && isset($_POST['sheng'])){
    include '../c/config.php';
   
    $openid='xxxx'.rand(1,9999);
    if (isset($_SESSION['openid'])){
       $openid=$_SESSION['openid'];
    }
    $name=addslashes(trim($_POST['name']));
    $sheng=addslashes(trim($_POST['sheng']));
    $phone=addslashes(trim($_POST['phone']));

    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
    
    $queryJ=$mysqli->query("SELECT id from `uinfo` where openid='".$openid."' limit 0,1 ");
    if($queryJ->num_rows>0){

    }else{
       if (!empty($sheng)) {
         $mysqli->query("INSERT INTO `uinfo` (`id`, `openid`, `sheng`,`name`,`phone`,`createtime`) VALUES (NULL,'".$openid."', '".$sheng."','".$name."','".$phone."', '".date("Y-m-d H:i:s")."')");
       }
    }
    
    $mysqli->close();

    echo json_encode(array('s'=>'y'));
}else{
    echo json_encode(array('s'=>'n'));
}

?>